﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BankInvest.InstrumentEditor.Controllers;

namespace BankInvest.InstrumentEditor
{
    public partial class InstrumentEditorForm : Form, IInstrumentEditorView
    {
        public InstrumentEditorForm()
        {
            InitializeComponent();

            _findByIdButton.Click += (o, s) => FindById();
            _saveButton.Click += (o, s) => Save();
        }

        public string Id
        {
            get { return _idTextBox.Text; }
            set { _idTextBox.Text = value; }
        }

        public string InstrumentName
        {
            get { return _nameTextBox.Text; }
            set { _nameTextBox.Text = value; }
        }

        public string Status
        {
            get { return _toolStripStatusLabel.Text; }
            set { _toolStripStatusLabel.Text = value; }
        }

        public IDictionary<int, string> InstrumentTypeIdNameDictionary
        {
            set { _typeComboBox.DataSource = value.ToList(); }
        }

        public int SelectedInstrumentTypeId
        {
            get { return (int)_typeComboBox.SelectedValue; }
            set { _typeComboBox.SelectedValue = value; }
        }

        public bool IsActive
        {
            get { return _activeCheckBox.Checked; }
            set { _activeCheckBox.Checked = value; }
        }

        public event Action FindById;
        public event Action Save;
    }
}
